<template>
	<!-- 任务中心item -->
	<view class="pull-number-item" v-if="info.type===4">
		<view class="head">
			<view class="left">
				拉运计划
			</view>
			<view class="cart-code">
				{{info.hphm}}
			</view>
		</view>
		<view class="center-box">
			<view class="left">
				<view class="addr-box start">
					<view class="icon-box">
						<view class="icon">
							起
						</view>
					</view>
					<view class="addr">
						{{info.startingPlace}}
					</view>
				</view>
				<view class="addr-box end" v-for="addr in getTerminusPlace" :key="addr">
					<view class="icon-box">
						<view class="icon">
							终
						</view>
					</view>
					<view class="addr">
						{{addr}}
					</view>
				</view>
			</view>
			<view class="right">

			</view>
		</view>
		<view class="bottom-box">
			<up-grid col="1" gap="12rpx" class="top">
				<up-grid-item>
					<view class="item">
						<view class="title">
							作业时段
						</view>
						<view class="val timeStep">
							<text>{{info.planStartTime}}</text>
							<image class="icon" src="/static/img/drivers/arrow.png"></image>
							<text>{{info.planEndTime}}</text>

						</view>
					</view>
				</up-grid-item>

			</up-grid>
			<view class="bottom">
				<Button1 class="btn" @click.stop="btnClick">出场确认</Button1>
			</view>
		</view>

	</view>
	<view class="pull-number-item" @click="itemClick" v-else>
		<view class="head">
			<view class="left">
				订单编号：{{info.code}}
			</view>
			<view class="cart-code">
				{{info.hphm}}
			</view>
		</view>
		<view class="center-box">
			<view class="left">
				<view class="addr-box start">
					<view class="icon-box">
						<view class="icon">
							起
						</view>
					</view>
					<view class="addr">
						{{info.startingPlace}}
					</view>
				</view>
				<view class="addr-box end" v-for="addr in getTerminusPlace" :key="addr">
					<view class="icon-box">
						<view class="icon">
							终
						</view>
					</view>
					<view class="addr">
						{{addr}}
					</view>
				</view>
			</view>
			<view class="right">
				<block v-if="info.type == 2">
					<view class="status-box" :class="info.transportStatus === '待签收' && 'danger'">
						<view class="status">
							{{info.transportStatus}}
						</view>
					</view>
				</block>
			</view>
		</view>
		<view class="bottom-box" v-if="info.type == 1">
			<up-grid col="2" gap="12rpx" class="top">
				<up-grid-item>
					<view class="item">
						<view class="title">
							创建时间
						</view>
						<view class="val">
							{{info.createTime}}
						</view>
					</view>
				</up-grid-item>
				<up-grid-item>
					<view class="item">
						<view class="title">
							类型
						</view>
						<view class="val">
							{{info.rockTypeName}}
						</view>
					</view>
				</up-grid-item>
			</up-grid>
			<view class="bottom">
				<Button1 class="btn" @click.stop="btnClick">出场确认</Button1>
			</view>
		</view>
		<view class="bottom-box" v-else-if="info.type == 2">
			<up-grid col="2" gap="12rpx" class="top">
				<up-grid-item>
					<view class="item">
						<view class="title">
							创建时间
						</view>
						<view class="val">
							{{info.outTime}}
						</view>
					</view>
				</up-grid-item>
				<up-grid-item>
					<view class="item">
						<view class="title">
							实际运输时长(分钟)
						</view>
						<view class="val">
							{{info.transportDuration}}
						</view>
					</view>
				</up-grid-item>
			</up-grid>
			<up-grid col="4" gap="12rpx" class="bottom">
				<up-grid-item>
					<view class="item">
						<view class="title">
							驾驶员
						</view>
						<view class="val">
							{{info.driverName}}
						</view>
					</view>
				</up-grid-item>
				<up-grid-item>
					<view class="item">
						<view class="title">
							签收人
						</view>
						<view class="val">
							{{info.signBy || ''}}
						</view>
					</view>
				</up-grid-item>
				<up-grid-item>
					<view class="item">
						<view class="title">
							类型
						</view>
						<view class="val">
							{{info.rockTypeName}}
						</view>
					</view>
				</up-grid-item>
				<up-grid-item>
					<view class="item">
						<view class="title">
							方量
						</view>
						<view class="val primary">
							{{info.volume}}
						</view>
					</view>
				</up-grid-item>
			</up-grid>
		</view>
		<view class="bottom-box" v-else-if="info.type == 3">
			<up-grid col="2" gap="12rpx" class="top">
				<up-grid-item>
					<view class="item">
						<view class="title">
							类型
						</view>
						<view class="val">
							{{info.rockTypeName}}
						</view>
					</view>
				</up-grid-item>
				<up-grid-item>
					<view class="item">
						<view class="title">
							方量
						</view>
						<view class="val primary">
							{{info.volume}}
						</view>
					</view>
				</up-grid-item>
			</up-grid>
			<view class="bottom">
				<view class="item create-time">
					<view class="title">
						创建时间
					</view>
					<view class="val">
						{{info.createTime}}
					</view>
				</view>
				<Button1 class="btn" @click.stop="btnClick">到场确认</Button1>
			</view>
		</view>
	</view>
</template>

<script setup lang="ts">
	import { computed } from 'vue';
	import Button1 from '@/components/button1/button1.vue';
	const emits = defineEmits(['btnClick'])

	// info.type 1--待执行 2--已完成  3--到场确认
	const props = defineProps({
		info: {
			type: Object,
			defautl: () => ({})
		}
	})
	console.log('1111', props.info);
	const getTerminusPlace = computed(() => {
		// console.log('信息', props.info);
		if (props.info?.terminusPlace && props.info?.terminusPlace !== '') {
			return props.info?.terminusPlace.split(',')
		} else {
			return ['']
		}
		// return ['']
	})
	// 按钮点击
	const btnClick = () => {
		emits('btnClick')
	}
	// item 点击
	const itemClick = () => {
		if (props.info?.type === 2) {
			emits('btnClick')
		}
	}
</script>

<style scoped lang="scss">
	.pull-number-item {
		margin-bottom: 20rpx;
		font-size: 24rpx;
		border-radius: 16rpx;
		background-color: #fff;
		overflow: hidden;

		.head {
			display: flex;
			justify-content: space-between;
			align-items: center;
			color: $primary-color;
			border-radius: 0rpx 0rpx 16rpx 0rpx;
			background: linear-gradient(90deg, #C6DEFF 0%, #D9E9FD 100%);

			.left {
				font-weight: bold;
				padding: 20rpx;
				// color: #fff;
			}

			.cart-code {
				// margin: 4rpx;
				padding: 20rpx 24rpx;
				border: 2rpx solid $primary-color;
				border-radius: 16rpx;
				background-color: #fff;
			}
		}

		.center-box {
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 26rpx 20rpx;

			.left {
				.addr-box {
					display: flex;
					align-items: center;

					&.end {
						margin-top: 20rpx;

						.icon-box {
							.icon {
								background-color: #39B791;
							}
						}
					}
				}

				.icon-box {
					display: flex;
					justify-content: center;
					align-items: center;
					margin-right: 8rpx;
					width: 44rpx;
					height: 44rpx;
					font-size: 20rpx;
					background-color: rgba(46, 135, 255, 0.1);
					border-radius: 50%;

					.icon {
						width: 32rpx;
						height: 32rpx;
						color: #fff;
						line-height: 32rpx;
						text-align: center;
						border-radius: 50%;
						background-color: $primary-color;

					}
				}
			}

			.right {
				.status-box {
					padding: 6rpx;
					width: 80rpx;
					height: 80rpx;
					color: $primary-color;
					text-align: center;
					line-height: 80rpx;
					border-radius: 50%;
					background-color: rgba(46, 135, 255, 0.1);
					transform: rotate(45deg);

					&.danger {
						color: $danger-color;
						background: rgba(235, 79, 81, 0.1);

						.status {
							background: rgba(235, 79, 81, 0.1);
						}
					}

					.status {
						border-radius: 50%;
						background-color: rgba(46, 135, 255, 0.1);
					}
				}
			}
		}

		.bottom-box {
			padding: 0rpx 20rpx;
			overflow: hidden;

			.bottom {
				margin-top: 12rpx;
				margin-bottom: 20rpx;
			}

			.item {
				padding: 14rpx 24rpx 18rpx;
				width: 100%;
				height: 100%;
				border-radius: 8rpx;
				background-color: #EFF6FE;
				box-sizing: border-box;

				.title {
					margin-bottom: 14rpx;
					color: #989DA5;
				}

				.val {
					min-height: 30rpx;
					font-weight: 500;

					&.timeStep {
						display: flex;
						justify-content: space-between;
						align-items: center;

						.icon {
							width: 46rpx;
							height: 28rpx;
						}
					}
				}

				.primary {
					color: $primary-color;
				}
			}

			.create-time {
				display: flex;
				align-items: center;

				.title {
					margin: 0;
					margin-right: 14rpx;
				}
			}

			.btn {
				float: right;
				margin-top: 20rpx;
				margin-bottom: 22rpx;
			}
		}
	}
</style>